<template>
  <div class="app-container">
    <br>
    <el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
      <el-table-column
          align="center"
          prop="id"
          label="ID"
          width="50">
      </el-table-column>
      <el-table-column
          align="center"
          prop="username"
          label="昵称"
          width="120">
      </el-table-column>
      <el-table-column
          align="center"
          prop="phone"
          label="手机号"
          width="130">
      </el-table-column>
      <el-table-column
          align="center"
          prop="password"
          label="密码"
          width="100">
      </el-table-column>
      <el-table-column
          align="center"
          prop="emil"
          label="邮件"
          width="100">
      </el-table-column>
      <el-table-column
          align="center"
          prop="type"
          label="用户类型"
          width="100">
      </el-table-column>
      <el-table-column
          align="center"
          prop="money"
          label="余额"
          width="120">
      </el-table-column>
      <el-table-column
          align="center"
          prop="sex"
          label="性别"
          width="120"
      >
      </el-table-column>
      <el-table-column
          align="center"
          prop="city"
          label="城市"
          width="100"
      >
      </el-table-column>
      <el-table-column prop="img" label="头像" align="center"  width="400" >
        <template #default="scope">
          <el-image :src="scope.row.img" style="width: 100px; height: 100px"></el-image>
        </template>
      </el-table-column>

      <el-table-column prop="status" label="状态" align="center" width="80">
      </el-table-column>
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
    />

  </div>
</template>

<script>
import {selectUser} from "../api/MyUser"

export default {
  name: "MyUser",
  data() {
    return {
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      tableData: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      queryParams: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {

    handleSelectionChange() {
    },

    /*,* 查询【请填写功能名称】列表 */
    getList() {
      selectUser(this.queryParams).then(res => {
        if (res.code === 200) {
          this.tableData = res.data
          for (const re of this.tableData) {
            if (re.status === 0) {
              re.status = '未注册'
            }  else {
              re.status = '已注册'
            }
            if (re.sex === 0) {
              re.sex = '男'
            } else {
              re.sex = '女'
            }
            if (re.type===1){
              re.type ='用户'
            }else if (re.type===2){
              re.type ='医师'
            }else {
              re.type ='代理商'
            }
          }
        } else {
          this.$message.error(res.msg)
        }
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>

